/* sow.t  SALES ORDER WRITE TRIGGER                                   */
/*Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                 */
/*All rights reserved worldwide.  This is an unpublished work.        */
/*V8:ConvertMode=NoConvert*/
/*********************************************************************/
/*  Program :sow.t                                                   */
/*  Author  :Ben Holmes                                              */
/*  Date    :03/19/95                                                */
/*  !Description : so_mstr WRITE trigger program                     */
/*          : In order to enhance this trigger to support additional */
/*          : interfaces, add a DO-END block similar to the one      */
/*          : used for the Warehousing Interface to (1) check for the*/
/*          : need to continue processing; (2) move the relevant     */
/*          : fields to an appropriate work area; and (3) call       */
/*          : one or more subprograms to continue processing.        */
/*          : This .t program should remain short, relying on        */
/*          : subprograms to perform most of the work.               */
/*********************************************************************/
/*                             MODIFY LOG                            */
/*********************************************************************/
/*Revision 8.5          Last Modified:  12/04/95 BY: BHolmes *J0FY*  */
/*Revision 8.5          Last Modified:  07/21/96 BY: fwy     *J0MB*  */
/*Revision 8.5          Last Modified:  07/22/96 BY: GWM     *J10D*  */
/*Revision 8.5          Last Modified:  07/27/96 BY: fwy     *J12B*  */
/*Revision 8.5          Last Modified:  01/07/97 BY: jpm     *J1DM*  */
/*Revision 9.1          Last Modified:  08/12/00 BY: *N0KN* myb       */
/*                                                                   */
/*                                                                   */
/*                                                                   */
/*********************************************************************/

TRIGGER PROCEDURE FOR WRITE OF SO_MSTR OLD BUFFER OLD_SO_MSTR.

/*J12B  if not can-find(first whl_mstr where whl_mstr.whl_act no-lock) */
/*J12B  then leave. */

    {mfdeclre.i }
    define new shared work-table wf_old_so_mstr like so_mstr.
    define new shared variable w-recid as recid.
    define new shared variable w-site-loc-id like whl_mstr.whl_src_dest_id.

    define variable w-file as character format "x(24)".


    /* Warehousing Interface processing */

    WI:
    do:

    /* If there is no active external warehouse that is flagged to
    receive sales order export transactions, then do not process */
/*J12B*/    if not can-find(first whl_mstr no-lock
/*J12B*/        where whl_mstr.whl_act and whl_mstr.whl_so_exp)
/*J12B*/    then leave WI.

    /* Do not process if multi-DB and not in central database */
/*J0MB*/if global_db ne "" and global_db ne sdbname(1) then leave WI.

    /* If no pertinent fields have been changed, then do not process */
/*J12B*/    if   (old_so_mstr.so_nbr      = so_mstr.so_nbr
/*J12B*/      and old_so_mstr.so_ord_date = so_mstr.so_ord_date
/*J12B*/      and old_so_mstr.so_due_date = so_mstr.so_due_date
/*J12B*/      and old_so_mstr.so_req_date = so_mstr.so_req_date
/*J12B*/      and old_so_mstr.so_rmks     = so_mstr.so_rmks
/*J12B*/      and old_so_mstr.so_fr_list  = so_mstr.so_fr_list
/*J12B*/      and old_so_mstr.so_shipvia  = so_mstr.so_shipvia
/*J12B*/      and old_so_mstr.so_ship     = so_mstr.so_ship
/*J12B*/      and old_so_mstr.so_stat     = so_mstr.so_stat
/*J12B*/      and old_so_mstr.so_sched    = so_mstr.so_sched
/*J12B*/      and old_so_mstr.so_user1    = so_mstr.so_user1
/*J12B*/      and old_so_mstr.so_user2    = so_mstr.so_user2
/*J12B*/      and old_so_mstr.so_po       = so_mstr.so_po
/*J12B*/      and old_so_mstr.so_cmtindx  = so_mstr.so_cmtindx)
/*J12B*/    then leave WI.

    /* Move so_mstr fields to work table for subsequent processing */
       assign w-recid = recid(so_mstr).
       create wf_old_so_mstr.
       if recid(wf_old_so_mstr)= -1 then .
       assign
           wf_old_so_mstr.so_nbr       = old_so_mstr.so_nbr
           wf_old_so_mstr.so_ord_date  = old_so_mstr.so_ord_date
           wf_old_so_mstr.so_due_date  = old_so_mstr.so_due_date
           wf_old_so_mstr.so_req_date  = old_so_mstr.so_req_date
           wf_old_so_mstr.so_rmks      = old_so_mstr.so_rmks
           wf_old_so_mstr.so_fr_list   = old_so_mstr.so_fr_list
           wf_old_so_mstr.so_shipvia   = old_so_mstr.so_shipvia
           wf_old_so_mstr.so_ship      = old_so_mstr.so_ship
           wf_old_so_mstr.so_stat      = old_so_mstr.so_stat
           wf_old_so_mstr.so_sched     = old_so_mstr.so_sched
           wf_old_so_mstr.so_user1     = old_so_mstr.so_user1
           wf_old_so_mstr.so_user2     = old_so_mstr.so_user2
/*J10D*/       wf_old_so_mstr.so_po        = old_so_mstr.so_po
/*J12B*/       wf_old_so_mstr.so_cmtindx   = old_so_mstr.so_cmtindx
       .

    /* Call subprogram to create export transactions for warehouses */
       w-file = "wisow.p".
/*J1DM*/ /* {gprun.i ""wisow.p""} */
/*J1DM*/   {gprunmo.i &module="WI"
                      &program="wisow.p"}

/*J12B*/end. /* WI */
